package com.hava.web.rest;

import org.springframework.web.bind.annotation.RequestMapping;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by zhanpeng on 15-4-10.
 */
public class Entity {

    public static String URL(Object that){
        
        System.out.println("Class Name: com.hava.web.rest.Entity | function : URL");
        
        Annotation annotation = that.getClass().getAnnotation(RequestMapping.class);

        System.out.println("annotation.simple.name:" + annotation.annotationType().getSimpleName());

        RequestMapping requestMapping = (RequestMapping)annotation;
        String [] values = requestMapping.value();
       
        if(values.length == 1)
        {
            System.out.println("value:" + values[0].toString());
            return values[0].toString();
        }
        else
        {
            System.err.println("Reflection " + that.getClass().getName() + " " + annotation.annotationType().getSimpleName() + " get value error");
            return null;
        }
    }
}
